package cn.newtest.common.xmlbean;

import java.io.File;

import net.risesoft.risereport.xmlbean.TemplatelistDocument;
import net.risesoft.risereport.xmlbean.TemplateDocument.Template;
import net.risesoft.risereport.xmlbean.TemplatelistDocument.Factory;
import net.risesoft.risereport.xmlbean.TemplatelistDocument.Templatelist;
import net.risesoft.risereport.xmlbeans.report.domain.ReportDataListDocument;

public class BYBTest {
	public static void main(String[] args) {
		BYBTest obj = new BYBTest();
		obj.test1();
		obj.test2();
	}
	public void test1(){
		try {
			File xmlFile = new File("D:\\xmlbeans-current\\Untitled10.xml");
			// Bind the instance to the generated XMLBeans types.
			//TemplatelistDocument emplistDoc = TemplatelistDocument.Factory.parse(xmlFile);
			TemplatelistDocument emplistDoc = TemplatelistDocument.Factory.newInstance();
			Templatelist list = emplistDoc.addNewTemplatelist();
			// Get and print pieces of the XML instance.
			//Templatelist list = emplistDoc.getTemplatelist();
			/*
			Template[] templates= list.getTemplateArray();
			for(int i=0;i<templates.length;i++){
			System.out.println(templates[i].getReporttemplateID());
			System.out.println(templates[i].getSpeciality());
			System.out.println(templates[i].getYear());
			}
			*/
			Template tmp2 = list.addNewTemplate();
			tmp2.setReporttemplateID("2");
			tmp2.setSpeciality("��ҵ");
			tmp2.setYear("2005");
			File xmlFile2 = new File("D:\\xmlbeans-current\\Test3.xml");
			emplistDoc.save(xmlFile2);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	public void test2(){
		try {
			System.out.print("ok1");
			ReportDataListDocument doc = ReportDataListDocument.Factory.newInstance();
			System.out.print("ok2");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}